<template>
	<view class="content">
		<image class="logo" src="/static/logo.png"></image>
		<view class="text-area">
			<text class="title">这是我的页面</text>
		</view>
		<view style="margin-top: 30rpx;width: 80%;">
			<input type="text" placeholder="请输入webview页面地址" style="border: 1rpx solid #ccc;" v-model="url">
			<br>
			<button @click="openWebview">打开webview页面</button>
		</view>
	</view>
</template>

<script>
	import XWebview from '@/driver/xwebview/index.js'
	export default {
		data() {
			return {
				url: null
			}
		},
		onLoad() {
			this.url = uni.getStorageSync('url');
		},
		onShow() {
			console.log('个人中心页显示')
		},
		methods: {
			openWebview() {
				if (this.url == null || this.url === '') {
					uni.showToast({
						title: '请输入url',
						icon: 'none',
						position: 'bottom',
						duration: 2000
					});
					return;
				}

				// if(!this.url.startsWith('http')){
				// 	this.url = 'http://' + this.url;
				// }
				uni.setStorage({
					key: 'url',
					data: this.url
				})
				const xw = XWebview.create(this.url, {
					styles: {
						statusbar: undefined
					}
				});
				xw.show();
				//xw.loadURL('/about'); //载入相对路径页面

			}
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>
